package com.BaseReuse;
import java.sql.*;

public class DataCounter {
	private String table;
	private Connection con;
	
	public DataCounter(String database,String table) throws Exception{
		this.table = table;
		
		con = new DBConnector(database).getCon();
	}
	
	public int count(String sql) throws SQLException{
		Statement stmt = con.createStatement();
		
		ResultSet result = stmt.executeQuery("select * from "+table+" where "+sql);
		
		int count=0;
		
		while(result.next()){
			count++;
		}
		
		return count;
	}
	public int count() throws SQLException{
		Statement stmt = con.createStatement();
		
		ResultSet result = stmt.executeQuery("select * from "+table);
		
		int count=0;
		
		while(result.next()){
			count++;
		}
		
		return count;
	}
}
